import Vec3 from "./vec3";
import BroadPhaseProxyCallback from "../broad-phase/broad-phase-proxy-callback";
import RayCastHit from "../shape/ray-cast-hit";

export default class RayCastWrapper extends BroadPhaseProxyCallback{
    constructor() {
        super();
        this.rayCastHit = new RayCastHit();
        this.begin = new Vec3();
        this.end = new Vec3();
        this.callback = null;
    }
    process(proxy) {
        let shape = proxy.userData;
        if(shape._geom.rayCast(this.begin,this.end,shape._transform,this.rayCastHit)) {
            this.callback.process(shape,this.rayCastHit);
        }
    }
}